#include<iostream>

using namespace std;


class Solution {
public:


    int two(int h)
    {
        int sum = 0;
        while (h > 0)
        {
            int x = h % 10;
            sum += x * x;
            h /= 10;
        }
        return sum;
    }

    bool isHappy(int n) {
        int slow = n;
        int fast = two(n);

        while (slow != fast)
        {
            slow = two(slow);
            fast = two(two(fast));
        }
        return slow == 1;

    }
};


int main()
{
    return 0;
}